<?php
header("Content-Type: text/plain;charset=utf-8");
require_once('dbconn.php');

class SuggDao{
	//添加建言
	public function insert($content,$propic,$date){
		//将suggestion的数据存入数据库
		$sql = "insert into sugg(sugg_content,sugg_propic,sugg_date) values ('".$content."','".$propic."','".$date."')";
		//echo $sql;
		$conn = new dbconn();
		$link = $conn->connection();
		$query = mysqli_query($link,$sql) ;
		return $query;
	}

	//删除建言
	public function delete($suggId){
		$sql = "delete from sugg where sugg_id =".$suggId;

		$conn = new dbconn();
		$link = $conn->connection();
		$query = mysqli_query($link,$sql) ;
		return $query;
	}

	//查询所有建言
	public function selectAll(){
		$sql = "select * from sugg";

		$conn = new dbconn();
		$link = $conn->connection();
		$query = mysqli_query($link,$sql) ;
		return $query;
	}

	//通过id查询单条建言
	public function selectById($suggId){
		$sql = "select * from sugg where sugg_id=".$suggId;

		$conn = new dbconn();
		$link = $conn->connection();
		$query = mysqli_query($link,$sql) ;
		return $query;
	}
}